//go:build sys
// +build sys

package config

import (
	"bytes"
	"encoding/json"
	"fmt"
)

func init() {
	configName := "config_sys.yaml"
	b, v := initConfig(configName)
	if Conf.ApiPort == 0 {
		Conf.ApiPort = 9002
	}
	if Conf.Platform == "" {
		Conf.Platform = "sys"
	}
	if b {
		bs, err := json.Marshal(Conf)
		if err != nil {
			panic(fmt.Sprintf("An error occurred while writing out the configuration file:%v", err))
		}
		err = v.ReadConfig(bytes.NewBuffer(bs))
		if err != nil {
			panic(fmt.Sprintf("An error occurred while writing out the configuration file:%v", err))
		}
		err = v.WriteConfigAs(configName)
		if err != nil {
			panic(fmt.Sprintf("An error occurred while writing out the configuration file:%v", err))
		}
	}
}
